#include <stdio.h>
#include <stdlib.h>

// singly node type
struct snode {
    int data;
    struct snode *next;
};
typedef struct snode sNode_t;

int searchLinkList(sNode_t *head, int x)
{
    static int moved=1;
    if (head == NULL)
        return 0;
    else {
        if (head->data == x)
            return moved;
        else {
            moved++;
            searchLinkList(head->next, x);
        }
    }
}

int main(int argc, char *argv[]) {
    int x = atoi(argv[1]);
    int arr[] = { 2, 3, 4, 10, 40 };

    sNode_t *list = NULL;
    for (int i=0; i<sizeof(arr)/sizeof(int); i++) {
        sNode_t *node = (sNode_t *)malloc(sizeof(sNode_t));
        node->data = arr[i];
        node->next = list;
        list = node;
    }

    int m =  searchLinkList(list, x); 
    if (m)
        printf("%d is in %d-th node of list\n", x, m);
    else
        printf("%d is not existed in the list\n", x);
}